package cn.kami.dbc;
import java.sql.*;
import cn.kami.dbc.DatabaseConnection;
public class MySQLDatabaseConnection implements DatabaseConnection{
	
	private static final String DBDRIVER = "org.gjt.mm.mysql.Driver";
	private static final String DBURL = "jdbc:mysql://localhost:3306/mydata";
	private static final String DBUSER = "root";
	private static final String DBPASSWORD = "password";

	private Connection conn = null;
	public MySQLDatabaseConnection(){
		try{
			Class.forName(DBDRIVER);
			conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD);
		}catch(Exception e){
			e.printStackTrace();
		}
	}

	public Connection getConnection(){
		return this.conn;
	}

	public void close(){
		if(this.conn != null){
			try{
				this.conn.close();
			}catch(SQLException e){
				e.printStackTrace();
			}
		}
	}
}